﻿@{
    ViewBag.Title = "Home Page";
}
<script src="~/Scripts/jquery-1.10.2.js"></script>


<div class="row">

    <button onclick="get()">get</button>
    <button onclick="post()">post</button>
    <button onclick="put()">put</button>
    <button onclick="deletes()">delete</button>
</div>
<script>
    var get = function () {
        var data=new Object();
        data.uName="";
        data .id=1;
        data.pageNum=23;
        data.pageSize=20;

       // debugger
        $.ajax({
             url: "http://localhost:25352/api/usersserviceprovider/",
            //url: "/api/usersserviceprovider/",
            // contentType: "application/json",
        
             data:JSON.stringify( data),

             type: "get",
            dataType: "json",
            success: function (data) {
                debugger
              //  location.href = "http://192.168.1.181:8090/api/usersserviceprovider/5";
            },
            error: function (data) {
                debugger
               // location.href = "http://192.168.1.181:8090/api/usersserviceprovider/5";
                debugger
            }
        });
    }
    var post = function () {
        var data = new Object();
        data.uName = "";
        data.id = 1;
        data.pageNum = 23;
        data.pageSize = 20;
        // debugger
        //$.ajax({
        //    url: "http://localhost:25352/api/usersserviceprovider/",
        //     data: {
        //         //rType:0,
        //         uName: "",
        //        //id: "",
        //        pageNum: 1,
        //         pageSize:20
        //    },
        //    type: "post",
        //   // dataType: "text",
        //  //  contentType: 'application/json',
        //    success: function (data) {
        //        debugger
        //        //  location.href = "http://192.168.1.181:8090/api/usersserviceprovider/5";
        //    },
        //    error: function (data) {
        //        debugger
        //        // location.href = "http://192.168.1.181:8090/api/usersserviceprovider/5";
              
        //    }
        //});
        $.ajax({
            type:'POST',
            url: 'http://127.0.0.1:25352/api/usersserviceprovider/',
            dataType:'text',
            data: {
                //rType:0,
                uName: "",
                //id: "",
                pageNum: 1,
                pageSize: 20
            },
            //data:{'name':name,'phone':phone,'e_mail':e_mail,'content':content},
            async: true,
            success:function(result){
                alert('我们会尽快与您联系,祝您生活愉快！');
            },
            error: function (data, type, err) {
                debugger
                console.log("ajax错误类型：" + type);
                console.log(err);
            }
        });
    }
    var put = function () {
        // debugger
        $.ajax({
            url: "http://localhost:25352/api/usersserviceprovider/",
            //url: "/api/usersserviceprovider/",
            // data: {
            //     //rType:0,
            //     uName: "",
            //    //id: "",
            //    pageNum: 23,
            //     pageSize:20
            //},

            type: "put",
            dataType: "json",
            success: function (data) {
                debugger
                //  location.href = "http://192.168.1.181:8090/api/usersserviceprovider/5";
            },
            error: function (data) {
                debugger
                // location.href = "http://192.168.1.181:8090/api/usersserviceprovider/5";
                debugger
            }
        });
    }
    var deletes = function () {
        // debugger
        $.ajax({
            url: "http://localhost:25352/api/usersserviceprovider/Delete",
            //url: "/api/usersserviceprovider/",
             data: {
                id:1
            },

            type: "delete",
            dataType: "json",
            success: function (data) {
                debugger
                //  location.href = "http://192.168.1.181:8090/api/usersserviceprovider/5";
            },
            error: function (data) {
                debugger
                // location.href = "http://192.168.1.181:8090/api/usersserviceprovider/5";
                debugger
            }
        });
    }
</script>